{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.7.1"
    },
    "toc": {
      "nav_menu": {},
      "number_sections": true,
      "sideBar": true,
      "skip_h1_title": false,
      "title_cell": "Table of Contents",
      "title_sidebar": "Contents",
      "toc_cell": false,
      "toc_position": {},
      "toc_section_display": true,
      "toc_window_display": false
    },
    "colab": {
      "name": "mlp-dropout.ipynb",
      "provenance": []
    },
    "widgets": {
      "application/vnd.jupyter.widget-state+json": {
        "13ddfb8e587a414098f0c574e0a22b0f": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_7fa83733f0474f84986c7c68a046d270",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_418d2282cac14274941c6834ae06a794",
              "IPY_MODEL_90eca9502dee468c950a3c2bf564afde"
            ]
          }
        },
        "7fa83733f0474f84986c7c68a046d270": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "418d2282cac14274941c6834ae06a794": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_d8597c2b7e6943d2acfcc0bb371ed201",
            "_dom_classes": [],
            "description": "",
            "_model_name": "FloatProgressModel",
            "bar_style": "info",
            "max": 1,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 1,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_18aebbe7a8b94f1e91116591c81512d8"
          }
        },
        "90eca9502dee468c950a3c2bf564afde": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_cba97f71f1a54454bae552b0e8fc8b3b",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": " 9920512/? [00:19&lt;00:00, 12161612.43it/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_4e6c9582c74345178016a0eff4f6694a"
          }
        },
        "d8597c2b7e6943d2acfcc0bb371ed201": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "initial",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "18aebbe7a8b94f1e91116591c81512d8": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "cba97f71f1a54454bae552b0e8fc8b3b": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "4e6c9582c74345178016a0eff4f6694a": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "7ec766d2461a493b8a1e30429a670cfe": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_7b17192db8c241dcb511c7409bd92c5f",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_62ecc825e1a7486685180ed48bedbbcb",
              "IPY_MODEL_8415980b109642809c8a65f29ba105ad"
            ]
          }
        },
        "7b17192db8c241dcb511c7409bd92c5f": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "62ecc825e1a7486685180ed48bedbbcb": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_63705df82f4c4d178b8f80803b2342a9",
            "_dom_classes": [],
            "description": "",
            "_model_name": "FloatProgressModel",
            "bar_style": "success",
            "max": 1,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 1,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_564284462e584ae8a4efffdb4ecd327a"
          }
        },
        "8415980b109642809c8a65f29ba105ad": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_b372cc4654724270824902f1cd89144b",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": " 32768/? [00:00&lt;00:00, 59173.11it/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_7886e1422c9f4e64862dc3cf3f59ede7"
          }
        },
        "63705df82f4c4d178b8f80803b2342a9": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "initial",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "564284462e584ae8a4efffdb4ecd327a": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "b372cc4654724270824902f1cd89144b": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "7886e1422c9f4e64862dc3cf3f59ede7": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "43818fc380174c9c83e6a6a150f07182": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_eebb70ed1614442ab8aa5f31c8408a91",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_c90529c8f83a4efb9b06edf968bff0ea",
              "IPY_MODEL_8abbe59b5c2c4207bae8fbbff373491b"
            ]
          }
        },
        "eebb70ed1614442ab8aa5f31c8408a91": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "c90529c8f83a4efb9b06edf968bff0ea": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_d956756b28774afc8ae4e9e3ef3d1d18",
            "_dom_classes": [],
            "description": "",
            "_model_name": "FloatProgressModel",
            "bar_style": "success",
            "max": 1,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 1,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_abc24fbf1c694845987e550d44e6cf5d"
          }
        },
        "8abbe59b5c2c4207bae8fbbff373491b": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_47d8239118ab41fc967c475ff8bc8662",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": " 1654784/? [00:00&lt;00:00, 3623205.68it/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_9b6cccfc0f5a435fb757ad1d66f97573"
          }
        },
        "d956756b28774afc8ae4e9e3ef3d1d18": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "initial",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "abc24fbf1c694845987e550d44e6cf5d": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "47d8239118ab41fc967c475ff8bc8662": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "9b6cccfc0f5a435fb757ad1d66f97573": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "305c0ae300f94afa8a75bf81657d3e04": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HBoxModel",
          "state": {
            "_view_name": "HBoxView",
            "_dom_classes": [],
            "_model_name": "HBoxModel",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "box_style": "",
            "layout": "IPY_MODEL_0bd95a73419e431cbaea18bffe858e1d",
            "_model_module": "@jupyter-widgets/controls",
            "children": [
              "IPY_MODEL_83f76b94d84a49c3aab3e0395bd15d90",
              "IPY_MODEL_6f3edf0cf7ad4898a3d133e19f499c62"
            ]
          }
        },
        "0bd95a73419e431cbaea18bffe858e1d": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "83f76b94d84a49c3aab3e0395bd15d90": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "FloatProgressModel",
          "state": {
            "_view_name": "ProgressView",
            "style": "IPY_MODEL_8e744543d67b45abb7db4db5973a3d8f",
            "_dom_classes": [],
            "description": "",
            "_model_name": "FloatProgressModel",
            "bar_style": "success",
            "max": 1,
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": 1,
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "orientation": "horizontal",
            "min": 0,
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_5e359276a27241dd9035d6637642f195"
          }
        },
        "6f3edf0cf7ad4898a3d133e19f499c62": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "HTMLModel",
          "state": {
            "_view_name": "HTMLView",
            "style": "IPY_MODEL_1e8ad88a62b84ad1874b5a0f692ac0d8",
            "_dom_classes": [],
            "description": "",
            "_model_name": "HTMLModel",
            "placeholder": "​",
            "_view_module": "@jupyter-widgets/controls",
            "_model_module_version": "1.5.0",
            "value": " 8192/? [00:00&lt;00:00, 43281.70it/s]",
            "_view_count": null,
            "_view_module_version": "1.5.0",
            "description_tooltip": null,
            "_model_module": "@jupyter-widgets/controls",
            "layout": "IPY_MODEL_fbfd546020a34a20aada49b3f47ecb63"
          }
        },
        "8e744543d67b45abb7db4db5973a3d8f": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "ProgressStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "ProgressStyleModel",
            "description_width": "initial",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "bar_color": null,
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "5e359276a27241dd9035d6637642f195": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        },
        "1e8ad88a62b84ad1874b5a0f692ac0d8": {
          "model_module": "@jupyter-widgets/controls",
          "model_name": "DescriptionStyleModel",
          "state": {
            "_view_name": "StyleView",
            "_model_name": "DescriptionStyleModel",
            "description_width": "",
            "_view_module": "@jupyter-widgets/base",
            "_model_module_version": "1.5.0",
            "_view_count": null,
            "_view_module_version": "1.2.0",
            "_model_module": "@jupyter-widgets/controls"
          }
        },
        "fbfd546020a34a20aada49b3f47ecb63": {
          "model_module": "@jupyter-widgets/base",
          "model_name": "LayoutModel",
          "state": {
            "_view_name": "LayoutView",
            "grid_template_rows": null,
            "right": null,
            "justify_content": null,
            "_view_module": "@jupyter-widgets/base",
            "overflow": null,
            "_model_module_version": "1.2.0",
            "_view_count": null,
            "flex_flow": null,
            "width": null,
            "min_width": null,
            "border": null,
            "align_items": null,
            "bottom": null,
            "_model_module": "@jupyter-widgets/base",
            "top": null,
            "grid_column": null,
            "overflow_y": null,
            "overflow_x": null,
            "grid_auto_flow": null,
            "grid_area": null,
            "grid_template_columns": null,
            "flex": null,
            "_model_name": "LayoutModel",
            "justify_items": null,
            "grid_row": null,
            "max_height": null,
            "align_content": null,
            "visibility": null,
            "align_self": null,
            "height": null,
            "min_height": null,
            "padding": null,
            "grid_auto_rows": null,
            "grid_gap": null,
            "max_width": null,
            "order": null,
            "_view_module_version": "1.2.0",
            "grid_template_areas": null,
            "object_position": null,
            "object_fit": null,
            "grid_auto_columns": null,
            "margin": null,
            "display": null,
            "left": null
          }
        }
      }
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "6SUwD1weUIXp",
        "colab_type": "text"
      },
      "source": [
        "Deep Learning Models -- A collection of various deep learning architectures, models, and tips for TensorFlow and PyTorch in Jupyter Notebooks.\n",
        "- Author: Sebastian Raschka\n",
        "- GitHub Repository: https://github.com/rasbt/deeplearning-models"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "qpv0XLsmUKrl",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "!pip install -q IPython\n",
        "!pip install -q ipykernel\n",
        "!pip install -q watermark\n",
        "!pip install -q matplotlib\n",
        "!pip install -q sklearn\n",
        "!pip install -q pandas\n",
        "!pip install -q pydot\n",
        "!pip install -q hiddenlayer\n",
        "!pip install -q graphviz"
      ],
      "execution_count": 1,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "Nt4w6FrcUIXr",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 121
        },
        "outputId": "45659d37-6853-49ed-8d1e-f57fb63cdee2"
      },
      "source": [
        "%load_ext watermark\n",
        "%watermark -a 'Sebastian Raschka' -v -p torch"
      ],
      "execution_count": 2,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Sebastian Raschka \n",
            "\n",
            "CPython 3.6.9\n",
            "IPython 5.5.0\n",
            "\n",
            "torch 1.5.1+cu101\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "hcMN3l3MUIXz",
        "colab_type": "text"
      },
      "source": [
        "- Runs on CPU or GPU (if available)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "sZhTAfxhUIX0",
        "colab_type": "text"
      },
      "source": [
        "# Model Zoo -- Multilayer Perceptron with Dropout"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "CIxuRKO7UIX1",
        "colab_type": "text"
      },
      "source": [
        "## Imports"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "6NfZzvNqUIX2",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "import time\n",
        "import numpy as np\n",
        "from torchvision import datasets\n",
        "from torchvision import transforms\n",
        "from torch.utils.data import DataLoader\n",
        "import torch.nn.functional as F\n",
        "import torch\n",
        "\n",
        "\n",
        "if torch.cuda.is_available():\n",
        "    torch.backends.cudnn.deterministic = True"
      ],
      "execution_count": 3,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ERrrYgMjUIX9",
        "colab_type": "text"
      },
      "source": [
        "## Settings and Dataset"
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "6UmdNbA3UIX-",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 441,
          "referenced_widgets": [
            "13ddfb8e587a414098f0c574e0a22b0f",
            "7fa83733f0474f84986c7c68a046d270",
            "418d2282cac14274941c6834ae06a794",
            "90eca9502dee468c950a3c2bf564afde",
            "d8597c2b7e6943d2acfcc0bb371ed201",
            "18aebbe7a8b94f1e91116591c81512d8",
            "cba97f71f1a54454bae552b0e8fc8b3b",
            "4e6c9582c74345178016a0eff4f6694a",
            "7ec766d2461a493b8a1e30429a670cfe",
            "7b17192db8c241dcb511c7409bd92c5f",
            "62ecc825e1a7486685180ed48bedbbcb",
            "8415980b109642809c8a65f29ba105ad",
            "63705df82f4c4d178b8f80803b2342a9",
            "564284462e584ae8a4efffdb4ecd327a",
            "b372cc4654724270824902f1cd89144b",
            "7886e1422c9f4e64862dc3cf3f59ede7",
            "43818fc380174c9c83e6a6a150f07182",
            "eebb70ed1614442ab8aa5f31c8408a91",
            "c90529c8f83a4efb9b06edf968bff0ea",
            "8abbe59b5c2c4207bae8fbbff373491b",
            "d956756b28774afc8ae4e9e3ef3d1d18",
            "abc24fbf1c694845987e550d44e6cf5d",
            "47d8239118ab41fc967c475ff8bc8662",
            "9b6cccfc0f5a435fb757ad1d66f97573",
            "305c0ae300f94afa8a75bf81657d3e04",
            "0bd95a73419e431cbaea18bffe858e1d",
            "83f76b94d84a49c3aab3e0395bd15d90",
            "6f3edf0cf7ad4898a3d133e19f499c62",
            "8e744543d67b45abb7db4db5973a3d8f",
            "5e359276a27241dd9035d6637642f195",
            "1e8ad88a62b84ad1874b5a0f692ac0d8",
            "fbfd546020a34a20aada49b3f47ecb63"
          ]
        },
        "outputId": "75151c62-379b-40f2-d07c-3af9478e0e38"
      },
      "source": [
        "##########################\n",
        "### SETTINGS\n",
        "##########################\n",
        "\n",
        "# Device\n",
        "device = torch.device(\"cuda:0\" if torch.cuda.is_available() else \"cpu\")\n",
        "\n",
        "# Hyperparameters\n",
        "random_seed = 1\n",
        "learning_rate = 0.1\n",
        "num_epochs = 10\n",
        "batch_size = 64\n",
        "dropout_prob = 0.5\n",
        "\n",
        "# Architecture\n",
        "num_features = 784\n",
        "num_hidden_1 = 128\n",
        "num_hidden_2 = 256\n",
        "num_classes = 10\n",
        "\n",
        "\n",
        "##########################\n",
        "### MNIST DATASET\n",
        "##########################\n",
        "\n",
        "# Note transforms.ToTensor() scales input images\n",
        "# to 0-1 range\n",
        "train_dataset = datasets.MNIST(root='data', \n",
        "                               train=True, \n",
        "                               transform=transforms.ToTensor(),\n",
        "                               download=True)\n",
        "\n",
        "test_dataset = datasets.MNIST(root='data', \n",
        "                              train=False, \n",
        "                              transform=transforms.ToTensor())\n",
        "\n",
        "\n",
        "train_loader = DataLoader(dataset=train_dataset, \n",
        "                          batch_size=batch_size, \n",
        "                          shuffle=True)\n",
        "\n",
        "test_loader = DataLoader(dataset=test_dataset, \n",
        "                         batch_size=batch_size, \n",
        "                         shuffle=False)\n",
        "\n",
        "# Checking the dataset\n",
        "for images, labels in train_loader:  \n",
        "    print('Image batch dimensions:', images.shape)\n",
        "    print('Image label dimensions:', labels.shape)\n",
        "    break"
      ],
      "execution_count": 4,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz to data/MNIST/raw/train-images-idx3-ubyte.gz\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "13ddfb8e587a414098f0c574e0a22b0f",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(FloatProgress(value=1.0, bar_style='info', max=1.0), HTML(value='')))"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "Extracting data/MNIST/raw/train-images-idx3-ubyte.gz to data/MNIST/raw\n",
            "Downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz to data/MNIST/raw/train-labels-idx1-ubyte.gz\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "7ec766d2461a493b8a1e30429a670cfe",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(FloatProgress(value=1.0, bar_style='info', max=1.0), HTML(value='')))"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "Extracting data/MNIST/raw/train-labels-idx1-ubyte.gz to data/MNIST/raw\n",
            "Downloading http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz to data/MNIST/raw/t10k-images-idx3-ubyte.gz\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "43818fc380174c9c83e6a6a150f07182",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(FloatProgress(value=1.0, bar_style='info', max=1.0), HTML(value='')))"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "Extracting data/MNIST/raw/t10k-images-idx3-ubyte.gz to data/MNIST/raw\n",
            "Downloading http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz to data/MNIST/raw/t10k-labels-idx1-ubyte.gz\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "display_data",
          "data": {
            "application/vnd.jupyter.widget-view+json": {
              "model_id": "305c0ae300f94afa8a75bf81657d3e04",
              "version_minor": 0,
              "version_major": 2
            },
            "text/plain": [
              "HBox(children=(FloatProgress(value=1.0, bar_style='info', max=1.0), HTML(value='')))"
            ]
          },
          "metadata": {
            "tags": []
          }
        },
        {
          "output_type": "stream",
          "text": [
            "Extracting data/MNIST/raw/t10k-labels-idx1-ubyte.gz to data/MNIST/raw\n",
            "Processing...\n",
            "Done!\n",
            "\n",
            "\n",
            "\n",
            "Image batch dimensions: torch.Size([64, 1, 28, 28])\n",
            "Image label dimensions: torch.Size([64])\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "stream",
          "text": [
            "/pytorch/torch/csrc/utils/tensor_numpy.cpp:141: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program.\n"
          ],
          "name": "stderr"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "_eyQlZIqUIYE",
        "colab_type": "code",
        "colab": {}
      },
      "source": [
        "##########################\n",
        "### MODEL\n",
        "##########################\n",
        "\n",
        "class MultilayerPerceptron(torch.nn.Module):\n",
        "\n",
        "    def __init__(self, num_features, num_classes):\n",
        "        super(MultilayerPerceptron, self).__init__()\n",
        "        \n",
        "        ### 1st hidden layer\n",
        "        self.linear_1 = torch.nn.Linear(num_features, num_hidden_1)\n",
        "        # The following to lones are not necessary, \n",
        "        # but used here to demonstrate how to access the weights\n",
        "        # and use a different weight initialization.\n",
        "        # By default, PyTorch uses Xavier/Glorot initialization, which\n",
        "        # should usually be preferred.\n",
        "        self.linear_1.weight.detach().normal_(0.0, 0.1)\n",
        "        self.linear_1.bias.detach().zero_()\n",
        "        \n",
        "        ### 2nd hidden layer\n",
        "        self.linear_2 = torch.nn.Linear(num_hidden_1, num_hidden_2)\n",
        "        self.linear_2.weight.detach().normal_(0.0, 0.1)\n",
        "        self.linear_2.bias.detach().zero_()\n",
        "        \n",
        "        ### Output layer\n",
        "        self.linear_out = torch.nn.Linear(num_hidden_2, num_classes)\n",
        "        self.linear_out.weight.detach().normal_(0.0, 0.1)\n",
        "        self.linear_out.bias.detach().zero_()\n",
        "        \n",
        "    def forward(self, x):\n",
        "        out = self.linear_1(x)\n",
        "        out = F.relu(out)\n",
        "        out = F.dropout(out, p=dropout_prob, training=self.training)\n",
        "        \n",
        "        out = self.linear_2(out)\n",
        "        out = F.relu(out)\n",
        "        out = F.dropout(out, p=dropout_prob, training=self.training)\n",
        "        \n",
        "        logits = self.linear_out(out)\n",
        "        probas = F.softmax(logits, dim=1)\n",
        "        return logits, probas\n",
        "\n",
        "    \n",
        "torch.manual_seed(random_seed)\n",
        "model = MultilayerPerceptron(num_features=num_features,\n",
        "                             num_classes=num_classes)\n",
        "\n",
        "model = model.to(device)\n",
        "\n",
        "optimizer = torch.optim.SGD(model.parameters(), lr=learning_rate)"
      ],
      "execution_count": 5,
      "outputs": []
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "afxD5qh5VPYg",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 220
        },
        "outputId": "ed97cb64-f30b-41a5-ac6a-1cd51decaa01"
      },
      "source": [
        "import hiddenlayer as hl\n",
        "hl.build_graph(model, torch.zeros([64, 28*28]).to(device))"
      ],
      "execution_count": 6,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "/usr/local/lib/python3.6/dist-packages/torch/onnx/symbolic_opset9.py:1310: UserWarning: Dropout is a training op and should not be exported in inference mode. Make sure to call eval() on the model, and to export it with param training=False.\n",
            "  warnings.warn(\"Dropout is a training op and should not be exported in inference mode. \"\n"
          ],
          "name": "stderr"
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "<hiddenlayer.graph.Graph at 0x7fe1a15637f0>"
            ],
            "image/svg+xml": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Generated by graphviz version 2.40.1 (20161225.0304)\n -->\n<!-- Title: %3 Pages: 1 -->\n<svg width=\"839pt\" height=\"108pt\"\n viewBox=\"0.00 0.00 839.00 108.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(72 72)\">\n<title>%3</title>\n<polygon fill=\"#ffffff\" stroke=\"transparent\" points=\"-72,36 -72,-72 767,-72 767,36 -72,36\"/>\n<!-- /outputs/9/10 -->\n<g id=\"node1\" class=\"node\">\n<title>/outputs/9/10</title>\n<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"194,-36 140,-36 140,0 194,0 194,-36\"/>\n<text text-anchor=\"start\" x=\"150\" y=\"-15\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Dropout</text>\n</g>\n<!-- 3720800354541618557 -->\n<g id=\"node6\" class=\"node\">\n<title>3720800354541618557</title>\n<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"334,-36 262,-36 262,0 334,0 334,-36\"/>\n<text text-anchor=\"start\" x=\"270\" y=\"-15\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Linear &gt; Relu</text>\n</g>\n<!-- /outputs/9/10&#45;&gt;3720800354541618557 -->\n<g id=\"edge4\" class=\"edge\">\n<title>/outputs/9/10&#45;&gt;3720800354541618557</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M194.1433,-18C210.787,-18 232.5325,-18 251.8223,-18\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"251.941,-21.5001 261.941,-18 251.9409,-14.5001 251.941,-21.5001\"/>\n<text text-anchor=\"middle\" x=\"228\" y=\"-21\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">64x128</text>\n</g>\n<!-- /outputs/13/14 -->\n<g id=\"node2\" class=\"node\">\n<title>/outputs/13/14</title>\n<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"456,-36 402,-36 402,0 456,0 456,-36\"/>\n<text text-anchor=\"start\" x=\"412\" y=\"-15\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Dropout</text>\n</g>\n<!-- /outputs/15 -->\n<g id=\"node3\" class=\"node\">\n<title>/outputs/15</title>\n<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"578,-36 524,-36 524,0 578,0 578,-36\"/>\n<text text-anchor=\"start\" x=\"538\" y=\"-15\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Linear</text>\n</g>\n<!-- /outputs/13/14&#45;&gt;/outputs/15 -->\n<g id=\"edge1\" class=\"edge\">\n<title>/outputs/13/14&#45;&gt;/outputs/15</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M456.0758,-18C473.0553,-18 495.1767,-18 513.7924,-18\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"514,-21.5001 523.9999,-18 513.9999,-14.5001 514,-21.5001\"/>\n<text text-anchor=\"middle\" x=\"490\" y=\"-21\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">64x256</text>\n</g>\n<!-- /outputs/16 -->\n<g id=\"node4\" class=\"node\">\n<title>/outputs/16</title>\n<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"695,-36 641,-36 641,0 695,0 695,-36\"/>\n<text text-anchor=\"start\" x=\"651\" y=\"-15\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Softmax</text>\n</g>\n<!-- /outputs/15&#45;&gt;/outputs/16 -->\n<g id=\"edge2\" class=\"edge\">\n<title>/outputs/15&#45;&gt;/outputs/16</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M578.1362,-18C593.6773,-18 613.4112,-18 630.4253,-18\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"630.6057,-21.5001 640.6056,-18 630.6056,-14.5001 630.6057,-21.5001\"/>\n<text text-anchor=\"middle\" x=\"609.5\" y=\"-21\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">64x10</text>\n</g>\n<!-- 4885423165967600272 -->\n<g id=\"node5\" class=\"node\">\n<title>4885423165967600272</title>\n<polygon fill=\"#e8e8e8\" stroke=\"#000000\" points=\"72,-36 0,-36 0,0 72,0 72,-36\"/>\n<text text-anchor=\"start\" x=\"8\" y=\"-15\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">Linear &gt; Relu</text>\n</g>\n<!-- 4885423165967600272&#45;&gt;/outputs/9/10 -->\n<g id=\"edge3\" class=\"edge\">\n<title>4885423165967600272&#45;&gt;/outputs/9/10</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M72.1431,-18C89.9959,-18 111.5175,-18 129.5449,-18\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"129.7013,-21.5001 139.7013,-18 129.7013,-14.5001 129.7013,-21.5001\"/>\n<text text-anchor=\"middle\" x=\"106\" y=\"-21\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">64x128</text>\n</g>\n<!-- 3720800354541618557&#45;&gt;/outputs/13/14 -->\n<g id=\"edge5\" class=\"edge\">\n<title>3720800354541618557&#45;&gt;/outputs/13/14</title>\n<path fill=\"none\" stroke=\"#000000\" d=\"M334.1431,-18C351.9959,-18 373.5175,-18 391.5449,-18\"/>\n<polygon fill=\"#000000\" stroke=\"#000000\" points=\"391.7013,-21.5001 401.7013,-18 391.7013,-14.5001 391.7013,-21.5001\"/>\n<text text-anchor=\"middle\" x=\"368\" y=\"-21\" font-family=\"Times\" font-size=\"10.00\" fill=\"#000000\">64x256</text>\n</g>\n</g>\n</svg>\n"
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 6
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "FEeP06D8UIYJ",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        },
        "outputId": "f118ec78-76db-4db9-85eb-9ed5c1ebf0b5"
      },
      "source": [
        "def compute_accuracy(net, data_loader):\n",
        "    net.eval()\n",
        "    correct_pred, num_examples = 0, 0\n",
        "    with torch.no_grad():\n",
        "        for features, targets in data_loader:\n",
        "            features = features.view(-1, 28*28).to(device)\n",
        "            targets = targets.to(device)\n",
        "            logits, probas = net(features)\n",
        "            _, predicted_labels = torch.max(probas, 1)\n",
        "            num_examples += targets.size(0)\n",
        "            correct_pred += (predicted_labels == targets).sum()\n",
        "        return correct_pred.float()/num_examples * 100\n",
        "    \n",
        "\n",
        "start_time = time.time()\n",
        "for epoch in range(num_epochs):\n",
        "    model.train()\n",
        "    for batch_idx, (features, targets) in enumerate(train_loader):\n",
        "        \n",
        "        features = features.view(-1, 28*28).to(device)\n",
        "        targets = targets.to(device)\n",
        "            \n",
        "        ### FORWARD AND BACK PROP\n",
        "        logits, probas = model(features)\n",
        "        cost = F.cross_entropy(logits, targets)\n",
        "        optimizer.zero_grad()\n",
        "        \n",
        "        cost.backward()\n",
        "        \n",
        "        ### UPDATE MODEL PARAMETERS\n",
        "        optimizer.step()\n",
        "        \n",
        "        ### LOGGING\n",
        "        if not batch_idx % 50:\n",
        "            print ('Epoch: %03d/%03d | Batch %03d/%03d | Cost: %.4f' \n",
        "                   %(epoch+1, num_epochs, batch_idx, \n",
        "                     len(train_loader), cost))\n",
        "\n",
        "\n",
        "    print('Epoch: %03d/%03d training accuracy: %.2f%%' % (\n",
        "          epoch+1, num_epochs, \n",
        "          compute_accuracy(model, train_loader)))\n",
        "\n",
        "    print('Time elapsed: %.2f min' % ((time.time() - start_time)/60))\n",
        "    \n",
        "print('Total Training Time: %.2f min' % ((time.time() - start_time)/60))"
      ],
      "execution_count": 7,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Epoch: 001/010 | Batch 000/938 | Cost: 3.1485\n",
            "Epoch: 001/010 | Batch 050/938 | Cost: 1.4630\n",
            "Epoch: 001/010 | Batch 100/938 | Cost: 0.9688\n",
            "Epoch: 001/010 | Batch 150/938 | Cost: 0.8256\n",
            "Epoch: 001/010 | Batch 200/938 | Cost: 0.9551\n",
            "Epoch: 001/010 | Batch 250/938 | Cost: 0.8162\n",
            "Epoch: 001/010 | Batch 300/938 | Cost: 0.7051\n",
            "Epoch: 001/010 | Batch 350/938 | Cost: 0.4990\n",
            "Epoch: 001/010 | Batch 400/938 | Cost: 0.4584\n",
            "Epoch: 001/010 | Batch 450/938 | Cost: 0.3880\n",
            "Epoch: 001/010 | Batch 500/938 | Cost: 0.4116\n",
            "Epoch: 001/010 | Batch 550/938 | Cost: 0.7491\n",
            "Epoch: 001/010 | Batch 600/938 | Cost: 0.7098\n",
            "Epoch: 001/010 | Batch 650/938 | Cost: 0.3282\n",
            "Epoch: 001/010 | Batch 700/938 | Cost: 0.4674\n",
            "Epoch: 001/010 | Batch 750/938 | Cost: 0.5632\n",
            "Epoch: 001/010 | Batch 800/938 | Cost: 0.6358\n",
            "Epoch: 001/010 | Batch 850/938 | Cost: 0.3775\n",
            "Epoch: 001/010 | Batch 900/938 | Cost: 0.4634\n",
            "Epoch: 001/010 training accuracy: 93.19%\n",
            "Time elapsed: 0.18 min\n",
            "Epoch: 002/010 | Batch 000/938 | Cost: 0.5405\n",
            "Epoch: 002/010 | Batch 050/938 | Cost: 0.3036\n",
            "Epoch: 002/010 | Batch 100/938 | Cost: 0.1994\n",
            "Epoch: 002/010 | Batch 150/938 | Cost: 0.3445\n",
            "Epoch: 002/010 | Batch 200/938 | Cost: 0.2382\n",
            "Epoch: 002/010 | Batch 250/938 | Cost: 0.3460\n",
            "Epoch: 002/010 | Batch 300/938 | Cost: 0.5256\n",
            "Epoch: 002/010 | Batch 350/938 | Cost: 0.2181\n",
            "Epoch: 002/010 | Batch 400/938 | Cost: 0.3808\n",
            "Epoch: 002/010 | Batch 450/938 | Cost: 0.3013\n",
            "Epoch: 002/010 | Batch 500/938 | Cost: 0.2367\n",
            "Epoch: 002/010 | Batch 550/938 | Cost: 0.3117\n",
            "Epoch: 002/010 | Batch 600/938 | Cost: 0.2735\n",
            "Epoch: 002/010 | Batch 650/938 | Cost: 0.2554\n",
            "Epoch: 002/010 | Batch 700/938 | Cost: 0.4193\n",
            "Epoch: 002/010 | Batch 750/938 | Cost: 0.4353\n",
            "Epoch: 002/010 | Batch 800/938 | Cost: 0.2331\n",
            "Epoch: 002/010 | Batch 850/938 | Cost: 0.5004\n",
            "Epoch: 002/010 | Batch 900/938 | Cost: 0.1995\n",
            "Epoch: 002/010 training accuracy: 94.74%\n",
            "Time elapsed: 0.35 min\n",
            "Epoch: 003/010 | Batch 000/938 | Cost: 0.4133\n",
            "Epoch: 003/010 | Batch 050/938 | Cost: 0.2686\n",
            "Epoch: 003/010 | Batch 100/938 | Cost: 0.3053\n",
            "Epoch: 003/010 | Batch 150/938 | Cost: 0.3391\n",
            "Epoch: 003/010 | Batch 200/938 | Cost: 0.3367\n",
            "Epoch: 003/010 | Batch 250/938 | Cost: 0.5061\n",
            "Epoch: 003/010 | Batch 300/938 | Cost: 0.5422\n",
            "Epoch: 003/010 | Batch 350/938 | Cost: 0.2047\n",
            "Epoch: 003/010 | Batch 400/938 | Cost: 0.2985\n",
            "Epoch: 003/010 | Batch 450/938 | Cost: 0.4060\n",
            "Epoch: 003/010 | Batch 500/938 | Cost: 0.1227\n",
            "Epoch: 003/010 | Batch 550/938 | Cost: 0.2380\n",
            "Epoch: 003/010 | Batch 600/938 | Cost: 0.4080\n",
            "Epoch: 003/010 | Batch 650/938 | Cost: 0.4271\n",
            "Epoch: 003/010 | Batch 700/938 | Cost: 0.4926\n",
            "Epoch: 003/010 | Batch 750/938 | Cost: 0.4119\n",
            "Epoch: 003/010 | Batch 800/938 | Cost: 0.2391\n",
            "Epoch: 003/010 | Batch 850/938 | Cost: 0.3260\n",
            "Epoch: 003/010 | Batch 900/938 | Cost: 0.1385\n",
            "Epoch: 003/010 training accuracy: 95.54%\n",
            "Time elapsed: 0.53 min\n",
            "Epoch: 004/010 | Batch 000/938 | Cost: 0.2654\n",
            "Epoch: 004/010 | Batch 050/938 | Cost: 0.3757\n",
            "Epoch: 004/010 | Batch 100/938 | Cost: 0.3066\n",
            "Epoch: 004/010 | Batch 150/938 | Cost: 0.2174\n",
            "Epoch: 004/010 | Batch 200/938 | Cost: 0.5300\n",
            "Epoch: 004/010 | Batch 250/938 | Cost: 0.2794\n",
            "Epoch: 004/010 | Batch 300/938 | Cost: 0.4683\n",
            "Epoch: 004/010 | Batch 350/938 | Cost: 0.4680\n",
            "Epoch: 004/010 | Batch 400/938 | Cost: 0.3815\n",
            "Epoch: 004/010 | Batch 450/938 | Cost: 0.1858\n",
            "Epoch: 004/010 | Batch 500/938 | Cost: 0.3451\n",
            "Epoch: 004/010 | Batch 550/938 | Cost: 0.2984\n",
            "Epoch: 004/010 | Batch 600/938 | Cost: 0.1797\n",
            "Epoch: 004/010 | Batch 650/938 | Cost: 0.2806\n",
            "Epoch: 004/010 | Batch 700/938 | Cost: 0.1345\n",
            "Epoch: 004/010 | Batch 750/938 | Cost: 0.2726\n",
            "Epoch: 004/010 | Batch 800/938 | Cost: 0.1050\n",
            "Epoch: 004/010 | Batch 850/938 | Cost: 0.3640\n",
            "Epoch: 004/010 | Batch 900/938 | Cost: 0.2502\n",
            "Epoch: 004/010 training accuracy: 96.20%\n",
            "Time elapsed: 0.70 min\n",
            "Epoch: 005/010 | Batch 000/938 | Cost: 0.1014\n",
            "Epoch: 005/010 | Batch 050/938 | Cost: 0.2355\n",
            "Epoch: 005/010 | Batch 100/938 | Cost: 0.4846\n",
            "Epoch: 005/010 | Batch 150/938 | Cost: 0.3071\n",
            "Epoch: 005/010 | Batch 200/938 | Cost: 0.2752\n",
            "Epoch: 005/010 | Batch 250/938 | Cost: 0.2526\n",
            "Epoch: 005/010 | Batch 300/938 | Cost: 0.2165\n",
            "Epoch: 005/010 | Batch 350/938 | Cost: 0.1320\n",
            "Epoch: 005/010 | Batch 400/938 | Cost: 0.1868\n",
            "Epoch: 005/010 | Batch 450/938 | Cost: 0.3578\n",
            "Epoch: 005/010 | Batch 500/938 | Cost: 0.1103\n",
            "Epoch: 005/010 | Batch 550/938 | Cost: 0.2980\n",
            "Epoch: 005/010 | Batch 600/938 | Cost: 0.2728\n",
            "Epoch: 005/010 | Batch 650/938 | Cost: 0.3905\n",
            "Epoch: 005/010 | Batch 700/938 | Cost: 0.1855\n",
            "Epoch: 005/010 | Batch 750/938 | Cost: 0.1100\n",
            "Epoch: 005/010 | Batch 800/938 | Cost: 0.4405\n",
            "Epoch: 005/010 | Batch 850/938 | Cost: 0.1745\n",
            "Epoch: 005/010 | Batch 900/938 | Cost: 0.4200\n",
            "Epoch: 005/010 training accuracy: 96.47%\n",
            "Time elapsed: 0.88 min\n",
            "Epoch: 006/010 | Batch 000/938 | Cost: 0.1378\n",
            "Epoch: 006/010 | Batch 050/938 | Cost: 0.1927\n",
            "Epoch: 006/010 | Batch 100/938 | Cost: 0.2291\n",
            "Epoch: 006/010 | Batch 150/938 | Cost: 0.1808\n",
            "Epoch: 006/010 | Batch 200/938 | Cost: 0.3774\n",
            "Epoch: 006/010 | Batch 250/938 | Cost: 0.1716\n",
            "Epoch: 006/010 | Batch 300/938 | Cost: 0.2867\n",
            "Epoch: 006/010 | Batch 350/938 | Cost: 0.2246\n",
            "Epoch: 006/010 | Batch 400/938 | Cost: 0.3296\n",
            "Epoch: 006/010 | Batch 450/938 | Cost: 0.2204\n",
            "Epoch: 006/010 | Batch 500/938 | Cost: 0.2163\n",
            "Epoch: 006/010 | Batch 550/938 | Cost: 0.1383\n",
            "Epoch: 006/010 | Batch 600/938 | Cost: 0.1956\n",
            "Epoch: 006/010 | Batch 650/938 | Cost: 0.0864\n",
            "Epoch: 006/010 | Batch 700/938 | Cost: 0.3900\n",
            "Epoch: 006/010 | Batch 750/938 | Cost: 0.2390\n",
            "Epoch: 006/010 | Batch 800/938 | Cost: 0.3244\n",
            "Epoch: 006/010 | Batch 850/938 | Cost: 0.0827\n",
            "Epoch: 006/010 | Batch 900/938 | Cost: 0.1857\n",
            "Epoch: 006/010 training accuracy: 96.61%\n",
            "Time elapsed: 1.06 min\n",
            "Epoch: 007/010 | Batch 000/938 | Cost: 0.2010\n",
            "Epoch: 007/010 | Batch 050/938 | Cost: 0.2411\n",
            "Epoch: 007/010 | Batch 100/938 | Cost: 0.2660\n",
            "Epoch: 007/010 | Batch 150/938 | Cost: 0.3081\n",
            "Epoch: 007/010 | Batch 200/938 | Cost: 0.3751\n",
            "Epoch: 007/010 | Batch 250/938 | Cost: 0.1981\n",
            "Epoch: 007/010 | Batch 300/938 | Cost: 0.3072\n",
            "Epoch: 007/010 | Batch 350/938 | Cost: 0.1048\n",
            "Epoch: 007/010 | Batch 400/938 | Cost: 0.3057\n",
            "Epoch: 007/010 | Batch 450/938 | Cost: 0.3702\n",
            "Epoch: 007/010 | Batch 500/938 | Cost: 0.1702\n",
            "Epoch: 007/010 | Batch 550/938 | Cost: 0.1309\n",
            "Epoch: 007/010 | Batch 600/938 | Cost: 0.1700\n",
            "Epoch: 007/010 | Batch 650/938 | Cost: 0.2051\n",
            "Epoch: 007/010 | Batch 700/938 | Cost: 0.1816\n",
            "Epoch: 007/010 | Batch 750/938 | Cost: 0.4536\n",
            "Epoch: 007/010 | Batch 800/938 | Cost: 0.0991\n",
            "Epoch: 007/010 | Batch 850/938 | Cost: 0.3392\n",
            "Epoch: 007/010 | Batch 900/938 | Cost: 0.1613\n",
            "Epoch: 007/010 training accuracy: 97.09%\n",
            "Time elapsed: 1.24 min\n",
            "Epoch: 008/010 | Batch 000/938 | Cost: 0.0898\n",
            "Epoch: 008/010 | Batch 050/938 | Cost: 0.1727\n",
            "Epoch: 008/010 | Batch 100/938 | Cost: 0.2921\n",
            "Epoch: 008/010 | Batch 150/938 | Cost: 0.1600\n",
            "Epoch: 008/010 | Batch 200/938 | Cost: 0.1016\n",
            "Epoch: 008/010 | Batch 250/938 | Cost: 0.1046\n",
            "Epoch: 008/010 | Batch 300/938 | Cost: 0.0972\n",
            "Epoch: 008/010 | Batch 350/938 | Cost: 0.1806\n",
            "Epoch: 008/010 | Batch 400/938 | Cost: 0.1816\n",
            "Epoch: 008/010 | Batch 450/938 | Cost: 0.5677\n",
            "Epoch: 008/010 | Batch 500/938 | Cost: 0.2589\n",
            "Epoch: 008/010 | Batch 550/938 | Cost: 0.1287\n",
            "Epoch: 008/010 | Batch 600/938 | Cost: 0.1794\n",
            "Epoch: 008/010 | Batch 650/938 | Cost: 0.0804\n",
            "Epoch: 008/010 | Batch 700/938 | Cost: 0.1260\n",
            "Epoch: 008/010 | Batch 750/938 | Cost: 0.2502\n",
            "Epoch: 008/010 | Batch 800/938 | Cost: 0.0733\n",
            "Epoch: 008/010 | Batch 850/938 | Cost: 0.2402\n",
            "Epoch: 008/010 | Batch 900/938 | Cost: 0.1435\n",
            "Epoch: 008/010 training accuracy: 97.23%\n",
            "Time elapsed: 1.42 min\n",
            "Epoch: 009/010 | Batch 000/938 | Cost: 0.1808\n",
            "Epoch: 009/010 | Batch 050/938 | Cost: 0.2472\n",
            "Epoch: 009/010 | Batch 100/938 | Cost: 0.1674\n",
            "Epoch: 009/010 | Batch 150/938 | Cost: 0.1200\n",
            "Epoch: 009/010 | Batch 200/938 | Cost: 0.1276\n",
            "Epoch: 009/010 | Batch 250/938 | Cost: 0.2326\n",
            "Epoch: 009/010 | Batch 300/938 | Cost: 0.1971\n",
            "Epoch: 009/010 | Batch 350/938 | Cost: 0.3050\n",
            "Epoch: 009/010 | Batch 400/938 | Cost: 0.1313\n",
            "Epoch: 009/010 | Batch 450/938 | Cost: 0.3280\n",
            "Epoch: 009/010 | Batch 500/938 | Cost: 0.1186\n",
            "Epoch: 009/010 | Batch 550/938 | Cost: 0.4076\n",
            "Epoch: 009/010 | Batch 600/938 | Cost: 0.2328\n",
            "Epoch: 009/010 | Batch 650/938 | Cost: 0.1231\n",
            "Epoch: 009/010 | Batch 700/938 | Cost: 0.2885\n",
            "Epoch: 009/010 | Batch 750/938 | Cost: 0.3806\n",
            "Epoch: 009/010 | Batch 800/938 | Cost: 0.0968\n",
            "Epoch: 009/010 | Batch 850/938 | Cost: 0.0284\n",
            "Epoch: 009/010 | Batch 900/938 | Cost: 0.1823\n",
            "Epoch: 009/010 training accuracy: 97.42%\n",
            "Time elapsed: 1.60 min\n",
            "Epoch: 010/010 | Batch 000/938 | Cost: 0.1907\n",
            "Epoch: 010/010 | Batch 050/938 | Cost: 0.1258\n",
            "Epoch: 010/010 | Batch 100/938 | Cost: 0.1824\n",
            "Epoch: 010/010 | Batch 150/938 | Cost: 0.0534\n",
            "Epoch: 010/010 | Batch 200/938 | Cost: 0.1593\n",
            "Epoch: 010/010 | Batch 250/938 | Cost: 0.3146\n",
            "Epoch: 010/010 | Batch 300/938 | Cost: 0.1491\n",
            "Epoch: 010/010 | Batch 350/938 | Cost: 0.1575\n",
            "Epoch: 010/010 | Batch 400/938 | Cost: 0.1629\n",
            "Epoch: 010/010 | Batch 450/938 | Cost: 0.1841\n",
            "Epoch: 010/010 | Batch 500/938 | Cost: 0.2373\n",
            "Epoch: 010/010 | Batch 550/938 | Cost: 0.1940\n",
            "Epoch: 010/010 | Batch 600/938 | Cost: 0.1392\n",
            "Epoch: 010/010 | Batch 650/938 | Cost: 0.1445\n",
            "Epoch: 010/010 | Batch 700/938 | Cost: 0.0959\n",
            "Epoch: 010/010 | Batch 750/938 | Cost: 0.0708\n",
            "Epoch: 010/010 | Batch 800/938 | Cost: 0.3521\n",
            "Epoch: 010/010 | Batch 850/938 | Cost: 0.1031\n",
            "Epoch: 010/010 | Batch 900/938 | Cost: 0.1203\n",
            "Epoch: 010/010 training accuracy: 97.58%\n",
            "Time elapsed: 1.78 min\n",
            "Total Training Time: 1.78 min\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "oJAxcdTwUIYS",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 35
        },
        "outputId": "8eec3843-d21c-4261-a52a-3f4bb97f1118"
      },
      "source": [
        "print('Test accuracy: %.2f%%' % (compute_accuracy(model, test_loader)))"
      ],
      "execution_count": 8,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Test accuracy: 96.86%\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "cell_type": "code",
      "metadata": {
        "id": "ZhuKxvC5UIYY",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 69
        },
        "outputId": "f667d2b8-061d-48d4-8ceb-78c1324a9b06"
      },
      "source": [
        "%watermark -iv"
      ],
      "execution_count": 9,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "torch 1.5.1+cu101\n",
            "numpy 1.18.5\n",
            "\n"
          ],
          "name": "stdout"
        }
      ]
    }
  ]
}